package tool.zyk.stardand;

import lombok.Data;
import tool.zyk.consts.RpcCommonConst;

/**
 * author: zyk
 * datetime: 2024/1/27 15:58
 * describe:
 */
@Data
public class RpcResponse {
    private Integer code;
    private String msg;
    private Object data;
    private String dataClass;

    public static RpcResponse ofSuccess(Object data, String dataClass) {
        RpcResponse rpcResponse = new RpcResponse();
        rpcResponse.setCode(RpcCommonConst.StatusCode.SUCCESS_CODE);
        rpcResponse.setMsg("success");
        rpcResponse.setData(data);
        rpcResponse.setDataClass(dataClass);
        return rpcResponse;
    }

    public static RpcResponse ofFailed(String errorMessage, Integer code) {
        RpcResponse rpcResponse = new RpcResponse();
        rpcResponse.setCode(code);
        rpcResponse.setMsg(errorMessage);
        return rpcResponse;
    }
}
